disp '==================='

subjects = {'LD','TA','MJ','MM','TJ'};
subjects= {'MJ'};

savefolder = ['weights'];
[g gg ggg]=mkdir(savefolder);

timecourseprefix = '';
timecourseprefix = 'BetaAtypical';

for SUB=subjects
    
    clear ('results','data','cfg','weights');
    load(['C:/Users/Yoren/Desktop/SVM/SVM Gijs/' SUB{1} '/SVM Results/ROIs 13-Jul-2010.mat']);
    disp(['subject ' SUB{1}]);
      
    figure();
    
    numROI = size(cfg.ROIs,2);  
    for ROI=1:numROI
        disp (['ROI ' num2str(ROI) ': ' results{ROI}.ROI]);
        weights = zeros(size(results{ROI}.([timecourseprefix cfg.timecourses{1}]).weights{1},1),size(cfg.timecourses,1));      

        for tc=1:size(cfg.timecourses,1)
            timecourse = [timecourseprefix cfg.timecourses{tc}];

            for SVMpass = 1:cfg.SVMruns 
                weights(:,tc) = weights(:,tc) + results{ROI}.(timecourse).weights{SVMpass};        
            end

            weights(:,tc) = weights(:,tc) / cfg.SVMruns;
        end
        
        subplot(ceil(numROI/2),2,ROI)
        plot(weights,'.');
        title([SUB{1} ', ROI: ' results{ROI}.ROI]);
    end
end
